Thread: [HELP] My capitalization program is not working

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Aug 2012
    Location
    Caloocan, Metro Manila, Philippines
    Posts
    17

    Unhappy [HELP] My capitalization program is not working

    The problem in my simple learning program is the, basically, it doesn't work and it prints out Segmentation fault (core dumped). I just want to know why it does that and what are the possible solutions.

    EDIT: That's not really the main problem. Even if I just assign a value to input, it still prints out the error.
    Code:
    #include <stdio.h>#include <string.h>
    
    
    char *cap(char *);
    
    
    int main(int argc, char *argv[]) {
    	char *input = "Hello World!";
    
    
    	printf("CAPITALIZED: ");
    	cap(input);
    
    
    	return 0;
    }
    
    
    char *cap(char *input) {
    	int i, n;
    
    
    	for(i = 0, n = strlen(input); i < n; i++) {
    		if(input[i] >= 'a' && input[i] <= 'z') {
    			input[i] -= ('a' - 'A');
    			printf("%c", input[i]);
    		}
    		printf("\n");
    	}
    }
    Last edited by Arbyn Acosta; 08-12-2012 at 07:53 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Capitalization
    By jacek in forum C Programming
    Replies: 1
    Last Post: 01-24-2010, 06:03 PM
  2. Program not working
    By HAssan in forum C Programming
    Replies: 5
    Last Post: 01-11-2009, 02:45 AM
  3. Standard for header file naming/capitalization?
    By skorman00 in forum C Programming
    Replies: 4
    Last Post: 04-21-2006, 02:38 AM
  4. capitalization trick
    By volk in forum C++ Programming
    Replies: 11
    Last Post: 04-05-2003, 07:12 PM
  5. Capitalization help
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 12-20-2001, 12:39 AM

Tags for this Thread